home *** CD-ROM | disk | FTP | other *** search
/ MacFormat 1995 January / macformat-020.iso / Shareware City / Applications / Alpha.5.96 folder / Tcl / SystemCode / latex.tcl < prev    next >
Encoding:
Text File  |  1994-09-20  |  69.6 KB  |  2 lines  |  [TEXT/ALFA]

  1. #############################################################################
  2. #############################################################################
  3. #
  4. # latex.tcl, version 2.3:  macros and bindings for LaTeX users
  5. #
  6. # -- see "LaTeX Help" and "LaTeX Key Bindings" on the Help menu
  7. # -- command summaries suitable for printing ("latex_commands.tex" 
  8. #    and "latex_keys.tex") will be found in the LaTeX folder.
  9. #
  10. #############################################################################
  11. #
  12. # version 1.1 and 1.2 (11/10/92) by Richard T. Austin (austin@eecs.umich.edu)
  13. # version 2.0--2.2 and 2.3 (9/15/94) by Tom Scavo (trscavo@syr.edu)
  14. #
  15. # If you make improvements to this file, please share them!
  16. #
  17. #############################################################################
  18. #############################################################################
  19.  
  20.  
  21. #--------------------------------------------------------------------------
  22. # Autoload procedure:
  23. #--------------------------------------------------------------------------
  24.  
  25. proc dummyTeX {} {}
  26.  
  27. #--------------------------------------------------------------------------
  28. # Other macro packages:
  29. #--------------------------------------------------------------------------
  30.  
  31. source "$HOME:Tcl:UserCode:smart.tcl"
  32.  
  33. #--------------------------------------------------------------------------
  34. # Flags and Variables:
  35. #--------------------------------------------------------------------------
  36.  
  37. set true 1
  38. set false 0
  39.  
  40. # Flags:
  41. newModeVar TeX optionIsMeta $false 1
  42. newModeVar TeX useBoxMacro $true 1
  43. newModeVar TeX useDollarSigns $false 1
  44. newModeVar TeX searchNoisily $true 1
  45. newModeVar TeX promptNoisily $true 1
  46. newModeVar TeX deleteObjectNoisily $true 1
  47. newModeVar TeX deleteEnvironmentNoisily $true 1
  48. newModeVar TeX wordWrap $true 1
  49. newModeVar TeX useStatusBar $true 1
  50.  
  51. # Variables:
  52. newModeVar TeX boxMacroName {BoxedEPSF} 0 
  53. newModeVar TeX funcExpr {\\((sub)*section|chapter)(\[.*\]|\*)?{([^{}]*)}} 0
  54. newModeVar TeX funcExprAlt {\\(section|chapter)(\[.*\]|\*)?{([^{}]*)}} 0 
  55. newModeVar TeX prefixString {% } 0
  56. newModeVar TeX wordBreak {(\\)?[a-zA-Z0-9]+} 0
  57. newModeVar TeX wordBreakPreface {([^a-zA-Z0-9\\]|.\\)} 0
  58.  
  59. #--------------------------------------------------------------------------
  60. # Mark Menu:
  61. #--------------------------------------------------------------------------
  62.  
  63. proc TeXMarkFile {} {
  64.     set end [maxPos]
  65.     set pos 0
  66.     set l {}
  67.  
  68.     # Remove all previous marks in this file?
  69.     set exp {\\((sub)*section|chapter)(\[.*\]|\*)?{([^{}]*)}}
  70.     while {![catch {search -f 1 -r 1 -m 0 -i 0 $exp $pos} res]} {
  71.         set start [lindex $res 0]
  72.         set end [lindex $res 1]
  73.         set text [getText $start $end]
  74.         if {[regexp {\{(.*)\}} $text dummy mtch]} {
  75.             set lab ""
  76.             if {[regexp {(sub)*section} $text title]} then {
  77.                 append lab $l [format "%[expr [string length $title] - 7]\s" ""]
  78.             } else {
  79.                 set l {   }
  80.             }
  81.             append lab $mtch
  82.             setNamedMark $lab [lineStart [expr $start - 1]] $start $start
  83.         }
  84.         set pos [expr $end+1]
  85.     }
  86. }
  87.  
  88. #--------------------------------------------------------------------------
  89. # Insertion routines:
  90. #--------------------------------------------------------------------------
  91.  
  92. # Returns a modified text string if the string $text is non-null, 
  93. # and the null string otherwise.  The argument 'operation' is a 
  94. # string directing 'doPrefixText' to either "insert" or "remove" 
  95. # $prefixString to/from each line of $text.  (This routine is
  96. # adapted from strings.tcl.)
  97. proc doPrefixText {operation prefixString text} {
  98.     if {$text == ""} {return ""}
  99.     set pref [quoteExpr $prefixString]
  100.     if {$operation == "insert"} then {
  101.         set trailChar ""
  102.         set textLen [string length $text]
  103.         if {[string index $text [expr $textLen-1]] == "\r"} then {
  104.             set text [string range $text 0 [expr $textLen-2]]
  105.             set trailChar "\r"
  106.         }
  107.         set str \r$prefixString
  108.         regsub -all \r $text $str text
  109.         return $prefixString$text$trailChar
  110.     } elseif {$operation == "remove"} then {
  111.         regsub -all \r$pref $text \r text
  112.         regsub ^$pref $text "" text
  113.         return $text
  114.     }
  115. }
  116.  
  117. # Shift each line of $text to the right by inserting a string of
  118. # $whitespace characters at the beginning of each line, returning
  119. # the resulting string.
  120. proc shiftTextRight {text whitespace} {
  121.     return [doPrefixText "insert" $whitespace $text]
  122. }
  123.  
  124. # Return a string of whitespace characters from the beginning 
  125. # of the line containing $pos up to the first non-whitespace 
  126. # character.
  127. proc getIndentation {pos} {
  128.     set text [getText [lineStart $pos] [nextLineStart $pos]]
  129.     regexp {^[ \t]*} $text theIndentation
  130.     return $theIndentation
  131. }
  132.  
  133. # Return an "indented carriage return" if any character preceding 
  134. # the insertion point (on the same line) is a non-whitespace 
  135. # character.  Otherwise, return the null string.
  136. proc openingCarriageReturn {} {
  137.     set pos [getPos]
  138.     set end $pos
  139.     set start [lineStart $pos]
  140.     set text [getText $start $end]
  141.     if {[isWhitespace $text]} then {
  142.         if {$start == $end} {return [getIndentation $pos]} {return ""}
  143.     } else {
  144.         return "\r[getIndentation $pos]"
  145.     }
  146. }
  147. # Return an "indented carriage return" if any character following 
  148. # the insertion point (on the same line) is a non-whitespace 
  149. # character.  Otherwise, return the null string.
  150. proc closingCarriageReturn {} {
  151.     set pos [selEnd]
  152.     if {[isSelection] && ($pos == [lineStart $pos])} then {
  153.         return "\r"
  154.     } else {
  155.         set start $pos
  156.         set end [nextLineStart $start]
  157.         set text [getText $start $end]
  158.         if {[isWhitespace $text]} then {
  159.             return ""
  160.         } else {
  161.             return "\r[getIndentation $pos]"
  162.         }
  163.     }
  164. }
  165.  
  166. # Insert an object at the insertion point. If there is a selection and the 
  167. # global variable 'deleteObjectNoisily' is false, quietly delete the selection 
  168. # first (just like 'paste'). Otherwise, prompt the user for the appropriate 
  169. # action. Returns true if the object is ultimately inserted, and false if the 
  170. # user cancels the operation. 
  171. proc insertObject {objectName} {
  172.     global deleteObjectNoisily
  173.     if {[isSelection]} then {
  174.         if {$deleteObjectNoisily} then {
  175.             case [askyesno -c "Delete selection?"] in {
  176.                 "yes" {deleteText [getPos] [selEnd]}
  177.                 "no" {backwardChar}
  178.                 "cancel" {return 0}
  179.             }
  180.         } else {
  181.             deleteText [getPos] [selEnd]
  182.         }
  183.     }
  184.     insertText $objectName
  185.     return 1
  186. }
  187.  
  188. # Insert an object at the insertion point. If there is a selection, wrap 
  189. # it inside the parameters $left and $right. Returns true if there is a 
  190. # selection (in which case it will wrap), and false otherwise. 
  191. proc wrapObject {left right} {
  192.     set currentPos [getPos]
  193.     set selected [isSelection]
  194.     if {$selected} then {
  195.         replaceText $currentPos [selEnd] $left [getSelect] $right
  196.     } else {
  197.         insertText $left "•" $right
  198.     }
  199.     goto $currentPos
  200.     nextTabStop
  201.     return $selected
  202. }
  203.  
  204. # Builds and returns a LaTeX environment, that is, a \begin...\end 
  205. # pair, given the name of the environment, an argument string, 
  206. # and the environment body.  The body should be passed to this 
  207. # procedure fully formatted, including indentation.
  208. proc buildEnvironment {envName envArg envBody trailingComment} {
  209.     set indent [getIndentation [getPos]]
  210.     set envStr [openingCarriageReturn]
  211.     append envStr "\\begin{" $envName "}"
  212.     append envStr $envArg "\r"
  213.     append envStr $envBody
  214.     append envStr $indent "\\end{" $envName "}$trailingComment"
  215.     append envStr [closingCarriageReturn]
  216.     return $envStr
  217. }
  218.  
  219. # Inserts a LaTeX environment with the specified name, argument, 
  220. # and body at the insertion point.  Positions the cursor at the 
  221. # beginning of the environment, leaving any subsequent action to the 
  222. # calling procedure.  Deletes the current selection quietly if the 
  223. # global variable 'deleteEnvironmentNoisily' is false; otherwise 
  224. # the user is prompted for directions.  Returns true if the 
  225. # environment is ultimately inserted, and false if the user cancels 
  226. # the operation.
  227. proc insertEnvironment {envName envArg envBody} {
  228.     global deleteEnvironmentNoisily
  229.     if {[isSelection]} then {
  230.         if {$deleteEnvironmentNoisily} then {
  231.             case [askyesno -c "Delete selection?"] in {
  232.                 "yes" {}
  233.                 "no" {backwardChar}
  234.                 "cancel" {return 0}
  235.             }
  236.         }
  237.     }
  238.     set start [getPos]
  239.     set end [selEnd]
  240.     set body [shiftTextRight $envBody [getIndentation $start]]
  241.     replaceText $start $end [buildEnvironment $envName $envArg $body "•"]
  242.     goto $start
  243.     return 1
  244. }
  245.  
  246. # Inserts an environment with the given name, argument, and body at 
  247. # the insertion point.  Positions the cursor at the beginning of 
  248. # the environment, leaving any subsequent action to the calling 
  249. # procedure.  If there is currently a selection, cut and paste it 
  250. # into the body of the new environment, maintaining proper 
  251. # indentation; otherwise, insert a tab stop into the body of the
  252. # environment.  Returns true if there is a selection, and false 
  253. # otherwise.
  254. proc wrapEnvironment {envName envArg envBody} {
  255.     set start [getPos]
  256.     set end [selEnd]
  257.     set indent [getIndentation $start]
  258.     if {[isSelection]} then {
  259.         set text [getSelect]
  260.         set textLen [string length $text]
  261.         if {[string index $text [expr $textLen-1]] != "\r"} then {
  262.             append text "\r"
  263.         }
  264.         if {$start == [lineStart $start]} then {
  265.             set body [shiftTextRight $text \t]
  266.         } else {
  267.             set body "$indent[shiftTextRight $text \t]"
  268.         }
  269.         append body [shiftTextRight $envBody $indent]
  270.         set environment [buildEnvironment $envName $envArg $body "•"]
  271.         set returnFlag 1
  272.     } else {
  273.         append body "$indent\t•\r" [shiftTextRight $envBody $indent]
  274.         set environment [buildEnvironment $envName $envArg $body "•"]
  275.         set returnFlag 0
  276.     }
  277.     replaceText $start $end $environment
  278.     goto $start
  279.     return $returnFlag
  280. }
  281.  
  282. # A generic call to 'wrapEnvironment' used throughout latex.tcl:
  283. proc doWrapEnvironment {envName} {
  284.     if {[wrapEnvironment $envName "" ""]} then {
  285.         set msgText "selection wrapped"
  286.     } else {
  287.         set msgText "enter body of $envName environment"
  288.     }
  289.     nextTabStop
  290.     message $msgText
  291. }
  292.  
  293. # Inserts a structured document template at the insertion point.  
  294. # Three arguments are required:  the class name of the document, a 
  295. # preamble string, and a string containing the body of the document.  
  296. # If the preamble is null, a generic \usepackage statement is 
  297. # inserted; otherwise, the preamble is inserted as is.  This routine 
  298. # does absolutely no error-checking (this is totally left up to the 
  299. # calling procedure) and returns nothing.
  300. proc insertDocument {className preamble docBody} {
  301.     set docStr "\\documentclass\[•\]{$className}\r"
  302.     if {$preamble == ""} then {
  303.         append docStr "\\usepackage{•}\r\r•\r\r"
  304.     } else {
  305.         append docStr $preamble
  306.     }
  307.     append docStr [buildEnvironment "document" "" $docBody "\r"]
  308.     set start [getPos]
  309.     set end [selEnd]
  310.     replaceText $start $end $docStr
  311.     goto $start
  312.     return
  313. }
  314.  
  315. # Inserts a document template at the insertion point given the 
  316. # class name of the document to be inserted.  If ALL of the current
  317. # document is selected, then the routine wraps the text inside a
  318. # generic document template.  If the file is empty, a bullet is 
  319. # inserted in place of the document body.  If neither of these 
  320. # conditions is true, an alert is displayed, and no action is taken.  
  321. # Returns true if wrapping occurs, and false otherwise.
  322. proc wrapDocument {className} {
  323.     if {[isEmptyFile]} then {
  324.         append body "\r•\r\r"
  325.         set returnFlag 0
  326.     } else {
  327.         if {[isDocumentSelected]} then {
  328.             set text [getSelect]
  329.             append body "\r$text\r"
  330.             set returnFlag 1
  331.         } else {
  332.             alertnote "nonempty file:  delete text or \'Select All\'\
  333.                 from the Edit menu"
  334.             return 0
  335.         }
  336.     }
  337.     set docStr "\\documentclass\[•\]{$className}\r"
  338.     append docStr "\\usepackage{•}\r\r•\r\r"
  339.     append docStr [buildEnvironment "document" "" $body "\r"]
  340.     set start [getPos]
  341.     set end [selEnd]
  342.     replaceText $start $end $docStr
  343.     goto $start
  344.     nextTabStop
  345.     message "enter style (or leave blank)"
  346.     return $returnFlag
  347. }
  348.  
  349. #--------------------------------------------------------------------------
  350. # Misc:
  351. #--------------------------------------------------------------------------
  352.  
  353. # Checks to see if there's a current selection.
  354. proc isSelection {} {
  355.     return [string length [getSelect]]
  356. }
  357.  
  358. # Checks to see if the current window is empty, sans whitespace.
  359. proc isEmptyFile {} {
  360.     return [isWhitespace [getText 0 [maxPos]]]
  361. }
  362.  
  363. # If there is a selection, make sure it's uppercase.  Otherwise, 
  364. # check to see if the character after the insertion point is uppercase.
  365. proc isUppercase {} {
  366.     if {[isSelection]} then {
  367.         set text [getSelect]
  368.     } else {
  369.         set text [lookAt [getPos]]
  370.     }
  371.     return [expr {[string toupper $text] == $text}]
  372. }
  373.  
  374. # Returns true if the entire window is selected, and false otherwise.
  375. proc isDocumentSelected {} {
  376.     return [expr {([getPos] == 0) && ([selEnd] == [maxPos])}]
  377. }
  378.  
  379. # Takes any string and tests whether or not that string contains all 
  380. # whitespace characters.  Carriage returns are considered whitespace, 
  381. # as are spaces and tabs.  Also returns true for the null string.
  382. proc isWhitespace {anyString} {
  383.     set len [string length $anyString]
  384.     for {set i 0} {$i < $len} {incr i} {
  385.         set c [string index $anyString $i]
  386.         if {($c != "\ ") && ($c != "\t") && ($c != "\r")} then {return 0}
  387.     }
  388.     return 1
  389. }
  390.  
  391. # Select the line containing the insertion point.
  392. proc lineSelect {} {
  393.     goto [lineStart [getPos]]
  394.     nextLineSelect
  395. }
  396.  
  397. # Check to see if the LaTeX symbol package has been loaded; if not, ask 
  398. # the user for directions.  Returns false if the package is not loaded
  399. # AND the user cancels the operation; otherwise, returns true.
  400. proc isSymbolPackageLoaded {} {
  401.     global searchNoisily
  402.     set begPos [getPos]
  403.     set endPos [selEnd]
  404.     set searchString {\\usepackage\{.*latexsym.*\}}
  405.     set searchResult [search -n -f 0 -m 0 -i 1 -r 1 $searchString $begPos]
  406.     if {[llength $searchResult] == 0} then {
  407.         case [askyesno -c "Insert the LaTeX symbol package?"] in {
  408.             "yes" {
  409.                 set searchString {\\documentclass(\[.*\])?\{.*\}}
  410.                 set searchResult [search -n -f 0 -m 0 -i 1 -r 1 $searchString $begPos]
  411.                 if {[llength $searchResult] == 0} then {
  412.                     set returnVal 0
  413.                     if {$searchNoisily} {beep}
  414.                     message "can't find \\documentclass"
  415.                 } else {
  416.                     goto [lindex $searchResult 1]
  417.                     set txt "\r\\usepackage\{latexsym\}"
  418.                     set offset [string length $txt]
  419.                     set begPos [expr $begPos + $offset]
  420.                     set endPos [expr $endPos + $offset]
  421.                     insertText $txt
  422.                     set returnVal 1
  423.                 }
  424.             }
  425.             "no" {set returnVal 1}
  426.             "cancel" {set returnVal 0}
  427.         }
  428.     } else {
  429.         set returnVal 1
  430.     }
  431.     select $begPos $endPos
  432.     return $returnVal
  433. }
  434.  
  435.  
  436. #############################################################################
  437. # Basic Commands
  438. #
  439. #############################################################################
  440.  
  441. proc typeset {} {
  442.     global latexPath
  443.     
  444.     # Initialization:
  445.     set isOzTeX 0
  446.     set isTextures 0
  447.     set isCMacTeX 0
  448.     
  449.     set currentWin [lindex [winNames -f] 0]
  450.     
  451.     # Check if a LaTeX app is running.  If not, open the app named in 
  452.     # $latexPath (if defined) or have the user select an app via a
  453.     # standard file dialog.
  454.     set appName [checkRunningL LaTeX {OTEX *TEX *XeT} latexPath]
  455.     
  456.     if {[string match {OzTeX*} $appName]} {
  457.         set isOzTeX 1
  458.     } elseif {[string match {Textures*} $appName]} {
  459.         set isTextures 1
  460.     } elseif {[string match {*tex} $appName]} {
  461.         set isCMacTeX 1
  462.     } else {
  463.         alertnote "Sorry, I don't know how to talk to \"$appName\"."
  464.         return
  465.     }
  466.     if {[winInfo dirty]} {
  467.         case [askyesno -c "Save \"$currentWin\"?"] in {
  468.             "yes" {save}
  469.             "no" {}
  470.             "cancel" {return}
  471.         }
  472.     }
  473.     switchTo $appName
  474.     if {$isOzTeX} {
  475.         sendOpenEvent -n $appName $currentWin
  476.     } elseif {$isTextures} {
  477.         sendOpenEvent -n $appName $currentWin
  478.     } elseif {$isCMacTeX} {
  479.         dosc -n $name -k 'aevt' -e 'odoc' -r -f $currentWin
  480.     }
  481. }
  482. # Slightly modified version of 'checkRunning' that looks for any of a
  483. # list of running apps.  (Courtesy of Tom Pollard)
  484. proc checkRunningL {prompt sigs path} {
  485.     global $path
  486.     foreach sig $sigs {
  487.         foreach proc [processes] {
  488.             if {[lindex $proc 1] == $sig} {
  489.                 return [lindex $proc 0]
  490.             }
  491.         }
  492.     }
  493.     if {![info exists $path] || ![file exists [set $path]]} {
  494.         if {[addAppPath $prompt $path]} return
  495.     }
  496.     if {[catch {getFileSig [set $path]}]} {
  497.         if {[addAppPath $prompt $path]} return
  498.     }
  499.     set sig [getFileSig [set $path]]
  500.     if {[catch {launch -f [set $path]}]} {
  501.         error "Problem with launching file (out of memory?)"
  502.     }
  503.     return [file tail [set $path]]
  504. #    return [checkRunning $name $sig $path]
  505. }
  506.  
  507.  
  508. #--------------------------------------------------------------------------
  509. # Goto:
  510. #--------------------------------------------------------------------------
  511.  
  512. # Switch to (but don't execute) any of the following applications.
  513. proc latex {} {
  514.     global latexPath
  515.     set sig ""
  516.     catch {string trim [lindex [getfinfo $latexPath] 1] '} sig
  517.     set name [checkRunning latex $sig latexPath]
  518.     if {![string length $name]} return
  519.     switchTo $name
  520. }
  521. proc bibtex {} {
  522.     global bibtexPath
  523.     set name [checkRunning BibTeX BIBt bibtexPath]
  524.     if {![string length $name]} return
  525.     switchTo $name
  526. }
  527. proc makeindex {} {
  528.     global makeindexPath
  529.     set name [checkRunning MakeIndex Midx makeindexPath]
  530.     if {![string length $name]} return
  531.     switchTo $name
  532. }
  533.  
  534. proc nextSection {} {
  535.     global searchNoisily funcExprAlt
  536.     set searchString $funcExprAlt
  537.     if {[isSelection]} then {
  538.         set searchPos [expr [getPos]+1]
  539.     } else {
  540.         set searchPos [getPos]
  541.     }
  542.     set searchResult [search -f 1 -r 1 -n $searchString $searchPos]
  543.     if {[string length $searchResult]} {
  544.         select [lindex $searchResult 0] [lindex $searchResult 1]
  545.     } else {
  546.         if {$searchNoisily} {beep}
  547.         message "next $funcExprAlt not found"
  548.     }
  549. }
  550. proc prevSection {} {
  551.     global searchNoisily funcExprAlt
  552.     set searchString $funcExprAlt
  553.     set searchResult [search -f 0 -r 1 -n $searchString [expr [getPos]-1]]
  554.     if {[string length $searchResult]} {
  555.         select [lindex $searchResult 0] [lindex $searchResult 1]
  556.     } else {
  557.         if {$searchNoisily} {beep}
  558.         message "previous $funcExprAlt not found"
  559.     }
  560. }
  561. proc nextSubsection {} {
  562.     global searchNoisily funcExpr
  563.     set searchString $funcExpr
  564.     if {[isSelection]} then {
  565.         set searchPos [expr [getPos]+1]
  566.     } else {
  567.         set searchPos [getPos]
  568.     }
  569.     set searchResult [search -f 1 -r 1 -n $searchString $searchPos]
  570.     if {[string length $searchResult]} {
  571.         select [lindex $searchResult 0] [lindex $searchResult 1]
  572.     } else {
  573.         if {$searchNoisily} {beep}
  574.         message "next $funcExpr not found"
  575.     }
  576. }
  577. proc prevSubsection {} {
  578.     global searchNoisily funcExpr
  579.     set searchString $funcExpr
  580.     set searchResult [search -f 0 -r 1 -n $searchString [expr [getPos]-1]]
  581.     if {[string length $searchResult]} {
  582.         select [lindex $searchResult 0] [lindex $searchResult 1]
  583.     } else {
  584.         if {$searchNoisily} {beep}
  585.         message "previous $funcExpr not found"
  586.     }
  587. }
  588.  
  589. proc gotoTabStop {directionIndicator} {
  590.     set searchResult [search -n -f $directionIndicator -m 0 -i 1 -r 0 {•} [getPos]]
  591.     if {[llength $searchResult] == 0} then {
  592.         return 0
  593.     } else {
  594.         goto [lindex $searchResult 0]
  595.         return 1
  596.     }
  597. }
  598. proc nextTabStop {} {
  599.     global searchNoisily
  600.     set forward 1
  601.     if {[gotoTabStop $forward]} then {
  602.         deleteChar
  603.     } else {
  604.         if {$searchNoisily} {beep}
  605.         message "tab stop not found"
  606.     }
  607. }
  608. proc prevTabStop {} {
  609.     global searchNoisily
  610.     set forward 0
  611.     if {[gotoTabStop $forward]} then {
  612.         deleteChar
  613.     } else {
  614.         if {$searchNoisily} {beep}
  615.         message "tab stop not found"
  616.     }
  617. }
  618. proc nthTabStop {numTabStops} {
  619.     global searchNoisily promptNoisily useStatusBar
  620.     if {$numTabStops == 0} then {
  621.         if {$promptNoisily && $useStatusBar} {beep}
  622.         catch {sPrompt "How many tab stops?" "3"} numTabStops
  623.         if {$numTabStops == "cancel"} then {
  624.             return
  625.         }
  626.     }
  627.     set currentPos [getPos]
  628.     if {$numTabStops > 0} {set forward 1} {set forward 0}
  629.     set maxits [expr abs($numTabStops)]
  630.     if {![gotoTabStop $forward]} then {
  631.         if {$searchNoisily} {beep}
  632.         message "tab stop not found"
  633.         goto $currentPos
  634.         return
  635.     }
  636.     for {set i 1} {$i < $maxits} {incr i} {
  637.         if {$forward} {forwardChar} {backwardChar}
  638.         if {![gotoTabStop $forward]} then {
  639.             if {$searchNoisily} {beep}
  640.             message "tab stop not found"
  641.             goto $currentPos
  642.             return
  643.         }
  644.     }
  645.     deleteChar
  646. }
  647.  
  648. #--------------------------------------------------------------------------
  649. # Utilities:
  650. #--------------------------------------------------------------------------
  651.  
  652. proc clearTabStops {} {
  653.     global searchNoisily
  654.     message "working..."
  655.     set messageString "selection"
  656.     if {[set start [getPos]] == [set end [selEnd]]} {
  657.         set messageString "document"
  658.         set start 0
  659.         set end [maxPos]
  660.     }
  661.     set text [getText $start $end]
  662.     if {[regsub -all {•} $text {} text]} then {
  663.         replaceText $start $end $text
  664.         set end [getPos]
  665.         select $start $end
  666.         message "tab stops removed from $messageString"
  667.     } else {
  668.         if {$searchNoisily} {beep}
  669.         message "no tab stops found in $messageString"
  670.     }
  671. }
  672.  
  673. proc convertDollarSigns {} {
  674.     global searchNoisily
  675.     message "working..."
  676.     set messageString "selection"
  677.     if {[set start [getPos]] == [set end [selEnd]]} {
  678.         set messageString "document"
  679.         set start 0
  680.         set end [maxPos]
  681.     }
  682.     set text [getText $start $end]
  683.     # Convert all displaymath mode:
  684.     set convert1 [regsub -all {\$\$([^$]*)\$\$} $text {\\[\1\\]} text]
  685.     # Convert all math mode:
  686.     set convert2 [regsub -all {\$([^$]*)\$} $text {\\(\1\\)} text]
  687.     if {$convert1 || $convert2} then {
  688.         replaceText $start $end $text
  689.         message "$messageString converted to LaTeX math mode format"
  690.     } else {
  691.         if {$searchNoisily} {beep}
  692.         message "no dollar signs found in $messageString"
  693.     }
  694. }
  695.  
  696. proc loadSymbolPackage {} {
  697.     global searchNoisily
  698.     set begPos [getPos]
  699.     set endPos [selEnd]
  700.     set searchString {\\usepackage\{.*latexsym.*\}}
  701.     set searchResult [search -n -f 1 -m 0 -i 1 -r 1 $searchString 0]
  702.     if {[llength $searchResult] == 0} then {
  703.         set searchString {\\documentclass(\[.*\])?\{.*\}}
  704.         set searchResult [search -n -f 1 -m 0 -i 1 -r 1 $searchString 0]
  705.         if {[llength $searchResult] == 0} then {
  706.             if {$searchNoisily} {beep}
  707.             message "can't find \\documentclass"
  708.         } else {
  709.             goto [lindex $searchResult 1]
  710.             set txt "\r\\usepackage\{latexsym\}"
  711.             set offset [string length $txt]
  712.             set begPos [expr $begPos + $offset]
  713.             set endPos [expr $endPos + $offset]
  714.             insertText $txt
  715.         }
  716.     } else {
  717.         if {$searchNoisily} {beep}
  718.         select $begPos $endPos
  719.         message "symbol package already loaded"
  720.     }
  721. }
  722.  
  723.  
  724. #############################################################################
  725. # Paragraph Mode Macros
  726. #
  727. #############################################################################
  728.  
  729. #--------------------------------------------------------------------------
  730. # Documents:
  731. #--------------------------------------------------------------------------
  732.  
  733. proc letter {} {
  734.     set    preamble "\r\\address\{%\r"
  735.     append preamble "    •    \\\\    % insert your name here\r"
  736.     append preamble "    •    \\\\    % insert your address here\r"
  737.     append preamble "    •    \\\\    % insert more address here\r"
  738.     append preamble "    •          % insert city-state-zip here\r"
  739.     append preamble "\}\r\r"
  740.     append preamble "\\date\{•\}  % optional\r"
  741.     append preamble "\\signature\{•\}\r\r"
  742.     set    body "\r\\begin\{letter\}\{%\r"
  743.     append body "    •    \\\\    % insert addressee's name here\r"
  744.     append body "    •    \\\\    % insert addressee's address here\r"
  745.     append body "    •    \\\\    % insert more address here\r"
  746.     append body "    •          % insert addressee's city-state-zip here\r"
  747.     append body "\}\r\r"
  748.     append body "\\opening\{Dear •,\}\r\r"
  749.     if {[isEmptyFile]} then {
  750.         append body "% BODY OF LETTER\r"
  751.         append body "•\r\r"
  752.     } else {
  753.         if {[isDocumentSelected]} then {
  754.             set text [getSelect]
  755. #             deleteText 0 [maxPos]
  756.             append body "$text\r"
  757.         } else {
  758.             alertnote "nonempty file:  delete text or \'Select All\'\
  759.                 from the Edit menu"
  760.             return
  761.         }
  762.     }
  763.     append body "\\closing\{Sincerely,\}\r\r"
  764.     append body "\\encl\{•\}\r"
  765.     append body "\\cc\{•\}\r\r"
  766.     append body "\\end\{letter\}\r\r"
  767.     insertDocument "letter" $preamble $body
  768.     nextTabStop
  769.     message "enter style (or leave blank)"
  770. }
  771. proc article {} {
  772.     wrapDocument "article"
  773. }
  774. proc report {} {
  775.     wrapDocument "report"
  776. }
  777. proc book {} {
  778.     wrapDocument "book"
  779. }
  780. proc slides {} {
  781.     wrapDocument "slides"
  782. }
  783. proc custom {} {
  784.     catch {prompt "What documentclass?" "article"} documentType
  785.     if {$documentType != "cancel"} then {
  786.         wrapDocument "$documentType" 
  787.     }
  788. }
  789.  
  790. proc getStyle {} {
  791.     catch {prompt "Choose a style:" "11pt" "" "11pt" "12pt" "titlepage" \
  792.                   "twocolumn" "twoside" "a4paper" "leqno" "fleqn"} styleName
  793.     if {$styleName != "cancel"} then {
  794.         return $styleName
  795.     } else {
  796.         return ""
  797.     }
  798. }
  799. proc insertStyle {style} {
  800.     global searchNoisily
  801.     set searchString {\\documentclass}
  802.     set searchResult [search -n -f 1 -m 0 -i 1 -r 1 $searchString 0]
  803.     if {[llength $searchResult] == 0} then {
  804.         if {$searchNoisily} {beep}
  805.         message "can\'t find \\documentclass"
  806.     } else {
  807.         set nextCharPos [lindex $searchResult 1]
  808.         goto $nextCharPos
  809.         set nextChar [lookAt $nextCharPos]
  810.         if {$nextChar == "\["} then {
  811.             forwardChar
  812.             insertText $style
  813.             if {[lookAt [getPos]] != "\]"} then {
  814.                 insertText ","
  815.             }
  816.         } elseif {$nextChar == "\{"} then {
  817.             insertText "\[$style\]"
  818.         } else {
  819.             alertnote "unrecognizable \\documentclass statement"
  820.         }
  821.     }
  822. }
  823. proc styles {} {
  824.     set style [getStyle]
  825.     if {$style != ""} then {
  826.         insertStyle $style
  827.     }
  828. }
  829. proc getPackage {} {
  830.     catch {prompt "Choose a package:" "latexsym" "" "amstex" "babel" \
  831.                   "color" "graphics" "ifthen" "latexsym" "makeidx" \
  832.                   "showidx"} packageName
  833.     if {$packageName != "cancel"} then {
  834.         return $packageName
  835.     } else {
  836.         return ""
  837.     }
  838. }
  839. proc insertPackage {package} {
  840.     global searchNoisily
  841.     set searchString {\\documentclass(\[.*\])?\{.*\}}
  842.     set searchResult [search -n -f 1 -m 0 -i 1 -r 1 $searchString 0]
  843.     if {[llength $searchResult] == 0} then {
  844.         if {$searchNoisily} {beep}
  845.         message "can\'t find \\documentclass"
  846.     } else {
  847.         goto [lindex $searchResult 1]
  848.         insertText "\r\\usepackage\{$package\}"
  849.     }
  850. }
  851. proc packages {} {
  852.     set package [getPackage]
  853.     if {$package != ""} then {
  854.         insertPackage $package
  855.     }
  856. }
  857. proc filecontents {} {
  858.     global searchNoisily
  859.     set searchString {\\documentclass}
  860.     set searchResult [search -n -f 1 -m 0 -i 1 -r 1 $searchString 0]
  861.     if {[llength $searchResult] == 0} then {
  862.         if {$searchNoisily} {beep}
  863.         message "can\'t find \\documentclass"
  864.         return
  865.     } else {
  866.         set prompt "File to be included:"
  867.         if {[catch {getfile $prompt} path]} then {
  868.             return
  869.         } else {
  870.             set fd [open $path]
  871.             set text [read $fd]
  872.             close $fd
  873.             regsub -all {
  874. } $text \r text
  875.             goto 0
  876.             set envName "filecontents"
  877.             set envArg "{[file tail $path]}"
  878.             replaceText 0 0 [buildEnvironment $envName $envArg "$text\r" "\r\r"]
  879.             goto 0
  880.             message "file included"
  881.         }
  882.     }
  883. }
  884.  
  885. #--------------------------------------------------------------------------
  886. # Page Layout:
  887. #--------------------------------------------------------------------------
  888.  
  889. proc maketitle {} {
  890.     global searchNoisily
  891.     set searchString {\\document(class|style)(\[.*\])?\{.*\}}
  892.     set searchResult [search -n -f 1 -m 0 -i 1 -r 1 $searchString 0]
  893.     if {[llength $searchResult] == 0} then {
  894.         if {$searchNoisily} {beep}
  895.         message "can\'t find \\documentclass or \\documentstyle"
  896.     } else {
  897.         set searchPos [lindex $searchResult 1]
  898.         set searchString {\\begin\{document\}}
  899.         set searchResult [search -n -f 1 -m 0 -i 1 -r 1 $searchString $searchPos]
  900.         if {[llength $searchResult] == 0} then {
  901.             if {$searchNoisily} {beep}
  902.             message "can\'t find \\begin\{document\}"
  903.         } else {
  904.             goto [lindex $searchResult 1]
  905.             set currentPos [getPos]
  906.             set txt "\r\r% Definition of title page:"
  907.             append txt "\r\\title\{"
  908.             append txt "\r\t•\r\}"
  909.             append txt "\r\\author\{"
  910.             append txt "\r\t•\t% insert author(s) here"
  911.             append txt "\r\}"
  912.             append txt "\r\\date\{•\}\t% optional"
  913.             append txt "\r\r\\maketitle"
  914.             insertText $txt
  915.             goto $currentPos
  916.             nextTabStop
  917.             message "insert title"
  918.         }
  919.     }
  920. }
  921. proc abstract {} { doWrapEnvironment "abstract" }
  922. proc titlepage {} { doWrapEnvironment "titlepage" }
  923. proc getPagestyle {} {
  924.     catch {prompt "Choose a pagestyle:" "plain" "" "plain" "empty" \
  925.                   "headings" "myheadings"} pagestyleName
  926.     if {$pagestyleName != "cancel"} then {
  927.         return $pagestyleName
  928.     } else {
  929.         return ""
  930.     }
  931. }
  932. proc pagestyle {} {
  933.     set pagestyleName [getPagestyle]
  934.     if {$pagestyleName != ""} then {
  935.         openingCarriageReturn
  936.         insertObject "\\pagestyle\{$pagestyleName\}"
  937.         closingCarriageReturn
  938.     }
  939. }
  940. proc thispagestyle {} {
  941.     set pagestyleName [getPagestyle]
  942.     if {$pagestyleName != ""} then {
  943.         openingCarriageReturn
  944.         insertObject "\\thispagestyle\{$pagestyleName\}"
  945.         closingCarriageReturn
  946.     }
  947. }
  948. proc getPagenumberingStyle {} {
  949.     catch {prompt "Choose a pagenumbering style:" "arabic" "" "arabic" \
  950.                   "roman" "Roman" "alph" "Alph"} pagenumberingStyle
  951.     if {$pagenumberingStyle != "cancel"} then {
  952.         return $pagenumberingStyle
  953.     } else {
  954.         return ""
  955.     }
  956. }
  957. proc pagenumbering {} {
  958.     set pagenumberingStyle [getPagenumberingStyle]
  959.     if {$pagenumberingStyle != ""} then {
  960.         openingCarriageReturn
  961.         insertObject "\\pagenumbering\{$pagenumberingStyle\}"
  962.         closingCarriageReturn
  963.     }
  964. }
  965. proc twocolumn {} {
  966.     openingCarriageReturn
  967.     insertObject "\\twocolumn"
  968.     closingCarriageReturn
  969. }
  970. proc onecolumn {} {
  971.     openingCarriageReturn
  972.     insertObject "\\onecolumn"
  973.     closingCarriageReturn
  974. }
  975.  
  976. #--------------------------------------------------------------------------
  977. # Sectioning:
  978. #--------------------------------------------------------------------------
  979.  
  980. proc part {} {
  981.     if {[wrapObject "\\part{" "}•"]} then {
  982.         message "don't forget the label"
  983.     } else {
  984.         message "type the part name and don't forget the label"
  985.     }
  986. }
  987. proc chapter {} {
  988.     if {[wrapObject "\\chapter{" "}•"]} then {
  989.         message "don't forget the label"
  990.     } else {
  991.         message "type the chapter name and don't forget the label"
  992.     }
  993. }
  994. proc section {} {
  995.     if {[wrapObject "\\section{" "}•"]} then {
  996.         message "don't forget the label"
  997.     } else {
  998.         message "type the section name and don't forget the label"
  999.     }
  1000. }
  1001. proc subsection {} {
  1002.     if {[wrapObject "\\subsection{" "}•"]} then {
  1003.         message "don't forget the label"
  1004.     } else {
  1005.         message "type the subsection name and don't forget the label"
  1006.     }
  1007. }
  1008. proc subsubsection {} {
  1009.     if {[wrapObject "\\subsubsection{" "}•"]} then {
  1010.         message "don't forget the label"
  1011.     } else {
  1012.         message "type the subsubsection name and don't forget the label"
  1013.     }
  1014. }
  1015. proc paragraph {} {
  1016.     if {[wrapObject "\\paragraph{" "}•"]} then {
  1017.         message "don't forget the label"
  1018.     } else {
  1019.         message "type the paragraph name and don't forget the label"
  1020.     }
  1021. }
  1022. proc subparagraph {} {
  1023.     if {[wrapObject "\\subparagraph{" "}•"]} then {
  1024.         message "don't forget the label"
  1025.     } else {
  1026.         message "type the subparagraph name and don't forget the label"
  1027.     }
  1028. }
  1029. proc appendix {} {insertObject "\\appendix"}
  1030.  
  1031. #--------------------------------------------------------------------------
  1032. # Text Style:
  1033. #--------------------------------------------------------------------------
  1034.  
  1035. proc emph {} {
  1036.     if {[wrapObject "\\emph{" "}•"]} then {
  1037.         message "selected text is emphasized"
  1038.     } else {
  1039.         message "enter text to be emphasized"
  1040.     }
  1041. }
  1042. proc textup {} {
  1043.     if {[wrapObject "\\textup{" "}•"]} then {
  1044.         message "selected text has upright shape"
  1045.     } else {
  1046.         message "enter text to have upright shape"
  1047.     }
  1048. }
  1049. proc textit {} {
  1050.     if {[wrapObject "\\textit{" "}•"]} then {
  1051.         message "selected text has italic shape"
  1052.     } else {
  1053.         message "enter text to have italic shape"
  1054.     }
  1055. }
  1056. proc textsl {} {
  1057.     if {[wrapObject "\\textsl{" "}•"]} then {
  1058.         message "selected text has slanted shape"
  1059.     } else {
  1060.         message "enter text to have slanted shape"
  1061.     }
  1062. }
  1063. proc textsc {} {
  1064.     if {[wrapObject "\\textsc{" "}•"]} then {
  1065.         message "selected text has small caps shape"
  1066.     } else {
  1067.         message "enter text to have small caps shape"
  1068.     }
  1069. }
  1070. proc textmd {} {
  1071.     if {[wrapObject "\\textmd{" "}•"]} then {
  1072.         message "selected text has been set in medium series"
  1073.     } else {
  1074.         message "enter text to be set in medium series"
  1075.     }
  1076. }
  1077. proc textbf {} {
  1078.     if {[wrapObject "\\textbf{" "}•"]} then {
  1079.         message "selected text has been set in bold series"
  1080.     } else {
  1081.         message "enter text to be set in bold series"
  1082.     }
  1083. }
  1084. proc textrm {} {
  1085.     if {[wrapObject "\\textrm{" "}•"]} then {
  1086.         message "selected text has been set with roman family"
  1087.     } else {
  1088.         message "enter text to be set using roman family"
  1089.     }
  1090. }
  1091. proc textsf {} {
  1092.     if {[wrapObject "\\textsf{" "}•"]} then {
  1093.         message "selected text has been set with sans serif family"
  1094.     } else {
  1095.         message "enter text to be set using sans serif family"
  1096.     }
  1097. }
  1098. proc texttt {} {
  1099.     if {[wrapObject "\\texttt{" "}•"]} then {
  1100.         message "selected text has been set with typewriter family"
  1101.     } else {
  1102.         message "enter text to be set using typewriter family"
  1103.     }
  1104. }
  1105. proc textnormal {} {
  1106.     if {[wrapObject "\\textnormal{" "}•"]} then {
  1107.         message "selected text has been set with normal style"
  1108.     } else {
  1109.         message "enter text to be set using normal style"
  1110.     }
  1111. }
  1112.  
  1113. #--------------------------------------------------------------------------
  1114. # Text Size:
  1115. #--------------------------------------------------------------------------
  1116.  
  1117. proc tiny {} {
  1118.     if {[wrapObject "{\\tiny " "}•"]} then {
  1119.         message "tiny text set"
  1120.     } else {
  1121.         message "enter tiny text"
  1122.     }
  1123. }
  1124. proc scriptsize {} {
  1125.     if {[wrapObject "{\\scriptsize " "}•"]} then {
  1126.         message "scriptsize text set"
  1127.     } else {
  1128.         message "enter scriptsize text"
  1129.     }
  1130. }
  1131. proc footnotesize {} {
  1132.     if {[wrapObject "{\\footnotesize " "}•"]} then {
  1133.         message "footnotesize text set"
  1134.     } else {
  1135.         message "enter footnotesize text"
  1136.     }
  1137. }
  1138. proc small {} {
  1139.     if {[wrapObject "{\\small " "}•"]} then {
  1140.         message "small text set"
  1141.     } else {
  1142.         message "enter small text"
  1143.     }
  1144. }
  1145. proc normalsize {} {
  1146.     if {[wrapObject "{\\normalsize " "}•"]} then {
  1147.         message "normalsize text set"
  1148.     } else {
  1149.         message "enter normalsize text"
  1150.     }
  1151. }
  1152. proc large {} {
  1153.     if {[wrapObject "{\\large " "}•"]} then {
  1154.         message "large text set"
  1155.     } else {
  1156.         message "enter large text"
  1157.     }
  1158. }
  1159. proc Large {} {
  1160.     if {[wrapObject "{\\Large " "}•"]} then {
  1161.         message "Large text set"
  1162.     } else {
  1163.         message "enter Large text"
  1164.     }
  1165. }
  1166. proc LARGE {} {
  1167.     if {[wrapObject "{\\LARGE " "}•"]} then {
  1168.         message "LARGE text set"
  1169.     } else {
  1170.         message "enter LARGE text"
  1171.     }
  1172. }
  1173. proc huge {} {
  1174.     if {[wrapObject "{\\huge " "}•"]} then {
  1175.         message "huge text set"
  1176.     } else {
  1177.         message "enter huge text"
  1178.     }
  1179. }
  1180. proc Huge {} {
  1181.     if {[wrapObject "{\\Huge " "}•"]} then {
  1182.         message "Huge text set"
  1183.     } else {
  1184.         message "enter Huge text"
  1185.     }
  1186. }
  1187.  
  1188. #--------------------------------------------------------------------------
  1189. # International:
  1190. #--------------------------------------------------------------------------
  1191.  
  1192. proc {ò} {} {
  1193.     if {[wrapObject "\\`{" "}•"]} then {
  1194.         message "accent set"
  1195.     } else {
  1196.         message "enter single character"
  1197.     }
  1198. }
  1199. proc {ó} {} {
  1200.     if {[wrapObject "\\'{" "}•"]} then {
  1201.         message "accent set"
  1202.     } else {
  1203.         message "enter single character"
  1204.     }
  1205. }
  1206. proc {ô} {} {
  1207.     if {[wrapObject "\\^{" "}•"]} then {
  1208.         message "accent set"
  1209.     } else {
  1210.         message "enter single character"
  1211.     }
  1212. }
  1213. proc {ö} {} {
  1214.     if {[wrapObject "\\\"{" "}•"]} then {
  1215.         message "accent set"
  1216.     } else {
  1217.         message "enter single character"
  1218.     }
  1219. }
  1220. proc {õ} {} {
  1221.     if {[wrapObject "\\~{" "}•"]} then {
  1222.         message "accent set"
  1223.     } else {
  1224.         message "enter single character"
  1225.     }
  1226. }
  1227. proc {ç} {} {
  1228.     if {[wrapObject "\\c{" "}•"]} then {
  1229.         message "accent set"
  1230.     } else {
  1231.         message "enter single character"
  1232.     }
  1233. }
  1234. proc {œ} {} {insertObject "\\oe"}
  1235. proc {Œ} {} {insertObject "\\OE"}
  1236. proc {æ} {} {insertObject "\\ae"}
  1237. proc {Æ} {} {insertObject "\\AE"}
  1238. proc {å} {} {insertObject "\\aa"}
  1239. proc {Å} {} {insertObject "\\AA"}
  1240. proc {ø} {} {insertObject "\\o"}
  1241. proc {Ø} {} {insertObject "\\O"}
  1242. proc {ß} {} {insertObject "\\ss"}
  1243. proc {¿} {} {insertObject "?`"}
  1244. proc {¡} {} {insertObject "!`"}
  1245.  
  1246. #--------------------------------------------------------------------------
  1247. # Environments:
  1248. #--------------------------------------------------------------------------
  1249.  
  1250. proc enumerate {} {
  1251.     global promptNoisily useStatusBar
  1252.     set envName "enumerate"
  1253.     if {$promptNoisily && $useStatusBar} {beep}
  1254.     catch {sPrompt "$envName:  how many items?" 3} numberItems
  1255.     if {$numberItems != "cancel"} then {
  1256.         set body "\t\\item  •"
  1257.         for {set i 1} {$i < $numberItems} {incr i} {
  1258.             append body "\r\r\t\\item  •"
  1259.         }
  1260.         append body "\r"
  1261.         if {[insertEnvironment $envName "" $body]} then {
  1262.             nextTabStop
  1263.             message "type first item"
  1264.         }
  1265.     }
  1266. }
  1267. proc itemize {} {
  1268.     global promptNoisily useStatusBar
  1269.     set envName "itemize"
  1270.     if {$promptNoisily && $useStatusBar} {beep}
  1271.     catch {sPrompt "$envName:  how many items?" 3} numberItems
  1272.     if {$numberItems != "cancel"} then {
  1273.         set body "\t\\item  •"
  1274.         for {set i 1} {$i < $numberItems} {incr i} {
  1275.             append body "\r\r\t\\item  •"
  1276.         }
  1277.         append body "\r"
  1278.         if {[insertEnvironment $envName "" $body]} then {
  1279.             nextTabStop
  1280.             message "type first item"
  1281.         }
  1282.     }
  1283. }
  1284. proc description {} {
  1285.     global promptNoisily useStatusBar
  1286.     set envName "description"
  1287.     if {$promptNoisily && $useStatusBar} {beep}
  1288.     catch {sPrompt "$envName: how many items?" 3} numberItems
  1289.     if {$numberItems != "cancel"} then {
  1290.         set body "\t\\item\[•\]  •"
  1291.         for {set i 1} {$i < $numberItems} {incr i} {
  1292.             append body "\r\r\t\\item\[•\]  •"
  1293.         }
  1294.         append body "\r"
  1295.         if {[insertEnvironment $envName "" $body]} then {
  1296.             nextTabStop
  1297.             message "type first item label"
  1298.         }
  1299.     }
  1300. }
  1301. proc thebibliography {} {
  1302.     global promptNoisily useStatusBar
  1303.     set envName "thebibliography"
  1304.     if {$promptNoisily && $useStatusBar} {beep}
  1305.     catch {sPrompt "$envName:  how many bibitems?" 3} numberItems
  1306.     if {$numberItems != "cancel"} then {
  1307.         set arg "{99}"
  1308.         set body "\t\\bibitem{•}\r\t•"
  1309.         for {set i 1} {$i < $numberItems} {incr i} {
  1310.             append body "\r\r\t\\bibitem{•}\r\t•"
  1311.         }
  1312.         append body "\r"
  1313.         if {[insertEnvironment $envName $arg $body]} then {
  1314.             nextTabStop
  1315.             message "type first bibitem key"
  1316.         }
  1317.     }
  1318. }
  1319. proc slide {} { doWrapEnvironment "slide" }
  1320. proc overlay {} { doWrapEnvironment "overlay" }
  1321. proc note {} { doWrapEnvironment "titlepage" }
  1322. proc figure {} {
  1323.     global useBoxMacro boxMacroName
  1324.     set envName "figure"
  1325.     set arg "\[tbp\]"
  1326.     if {$useBoxMacro} then {
  1327.         set body "\t\\centerline{\\$boxMacroName{•}}\r"
  1328.     }
  1329.     append body "\t\\caption{•}\r"
  1330.     append body "\t\\protect\\label{•}\r"
  1331.     if {$useBoxMacro} then {
  1332.         if {[insertEnvironment $envName $arg $body]} then {
  1333.             set msgText "enter filename"
  1334.         } else {
  1335.             return
  1336.         }
  1337.     } else {
  1338.         if {[wrapEnvironment $envName $arg $body]} then {
  1339.             set msgText "enter caption"
  1340.         } else {
  1341.             set msgText "enter body of $envName environment"
  1342.         }
  1343.     }
  1344.     nextTabStop
  1345.     message $msgText
  1346. }
  1347. proc table {} {
  1348.     set envName "table"
  1349.     set arg "\[tbp\]"
  1350.     append body "\t\\caption{•}\r"
  1351.     append body "\t\\protect\\label{•}\r"
  1352.     if {[wrapEnvironment $envName $arg $body]} then {
  1353.         set msgText "enter caption"
  1354.     } else {
  1355.         set msgText "enter body of $envName environment"
  1356.     }
  1357.     nextTabStop
  1358.     message $msgText
  1359. }
  1360. proc buildRow {jmax} {
  1361.     set txt "•"
  1362.     for {set j 1} {$j < $jmax} {incr j} {
  1363.         append txt " & •"
  1364.     }
  1365.     return $txt
  1366. }
  1367. proc tabular {} {
  1368.     global promptNoisily useStatusBar
  1369.     set envName "tabular"
  1370.     if {$promptNoisily && $useStatusBar} {beep}
  1371.     catch {sPrompt "$envName:  how many rows?" 3} numberRows
  1372.     if {$numberRows != "cancel"} then {
  1373.         if {$promptNoisily && $useStatusBar} {beep}
  1374.         catch {sPrompt "$envName:  how many columns?" 3} numberCols
  1375.         if {$numberCols != "cancel"} then {
  1376.             set arg "{|"
  1377.             for {set j 1} {$j <= $numberCols} {incr j} {
  1378.                 append arg "c|"
  1379.             }
  1380.             append arg "}"
  1381.             set body "\t\\hline\r"
  1382.             for {set i 1} {$i <= $numberRows} {incr i} {
  1383.                 append body "\t[buildRow $numberCols]"
  1384.                 append body "  \\\\\r\t\\hline\r"
  1385.             }
  1386.             if {[insertEnvironment $envName $arg $body]} then {
  1387.                 nextTabStop
  1388.                 message "type first item"
  1389.             }
  1390.         }
  1391.     }
  1392. }
  1393. proc verbatim {} { doWrapEnvironment "verbatim" }
  1394. proc quote {} { doWrapEnvironment "quote" }
  1395. proc quotation {} { doWrapEnvironment "quotation" }
  1396. proc verse {} { doWrapEnvironment "verse" }
  1397. proc flushleft {} { doWrapEnvironment "flushleft" }
  1398. proc center {} { doWrapEnvironment "center" }
  1399. proc flushright {} { doWrapEnvironment "flushright" }
  1400. proc general {} {
  1401.     catch {prompt "What environment?" "center"} environmentName
  1402.     if {$environmentName != "cancel"} {
  1403.         doWrapEnvironment "$environmentName"
  1404.     }
  1405. }
  1406.  
  1407. #--------------------------------------------------------------------------
  1408. # Boxes:
  1409. #--------------------------------------------------------------------------
  1410.  
  1411. proc mbox {} {
  1412.     if {[wrapObject "\\mbox{" "}•"]} then {
  1413.         message "mbox set"
  1414.     } else {
  1415.         message "enter text"
  1416.     }
  1417. }
  1418. proc makebox {} {
  1419.     if {[wrapObject "\\makebox\[•\]\[•\]{" "}•"]} then {
  1420.         message "makebox set; enter the width and position"
  1421.     } else {
  1422.         message "enter the width and position of the makebox, then the text"
  1423.     }
  1424. }
  1425. proc fbox {} {
  1426.     if {[wrapObject "\\fbox{" "}•"]} then {
  1427.         message "fbox set"
  1428.     } else {
  1429.         message "enter text"
  1430.     }
  1431. }
  1432. proc framebox {} {
  1433.     if {[wrapObject "\\framebox\[•\]\[•\]{" "}•"]} then {
  1434.         message "framebox set; enter the width and position"
  1435.     } else {
  1436.         message "enter the width and position of the framebox, then the text"
  1437.     }
  1438. }
  1439. proc newsavebox {} {
  1440.     if {[wrapObject "\\newsavebox{" "}•"]} then {
  1441.         message "newsavebox defined"
  1442.     } else {
  1443.         message "enter the command name of the sbox or savebox"
  1444.     }
  1445. }
  1446. proc sbox {} {
  1447.     if {[wrapObject "\\sbox{•}{" "}•"]} then {
  1448.         message "sbox set; enter the command name"
  1449.     } else {
  1450.         message "enter the command name of the sbox, then the text"
  1451.     }
  1452. }
  1453. proc savebox {} {
  1454.     if {[wrapObject "\\savebox{•}\[•\]\[•\]{" "}•"]} then {
  1455.         message "savebox set; enter the command name"
  1456.     } else {
  1457.         message "enter the command name of the savebox"
  1458.     }
  1459. }
  1460. proc usebox {} {
  1461.     if {[wrapObject "\\usebox{" "}•"]} then {
  1462.         message "usebox declared"
  1463.     } else {
  1464.         message "enter the command name of the sbox or savebox"
  1465.     }
  1466. }
  1467. proc raisebox {} {
  1468.     if {[wrapObject "\\raisebox{•}\[•\]\[•\]{" "}•"]} then {
  1469.         message "raisebox set; enter the displacement"
  1470.     } else {
  1471.         message "enter the displacement of the raisebox"
  1472.     }
  1473. }
  1474. proc parbox {} {
  1475.     if {[wrapObject "\\parbox\[•\]\{•\}{" "}•"]} then {
  1476.         message "parbox set; enter the position and width"
  1477.     } else {
  1478.         message "enter the position and width of the parbox, then the text"
  1479.     }
  1480. }
  1481. proc minipage {} {
  1482.     set arg "\[•\]{•}"
  1483.     wrapEnvironment "minipage" $arg ""
  1484.     nextTabStop
  1485.     message "enter the position of the minipage, then the width"
  1486. }
  1487. proc rule {} {
  1488.     insertObject "\\rule\[•\]\{•\}{•}•"
  1489.     nthTabStop -4
  1490.     message "enter the displacement of the rule, then width and height"
  1491. }
  1492.  
  1493. #--------------------------------------------------------------------------
  1494. # Misc:
  1495. #--------------------------------------------------------------------------
  1496.  
  1497. proc ldots {} {insertObject "\\ldots"}
  1498. proc {en-dash} {} {insertObject "--"}
  1499. proc {em-dash} {} {insertObject "---"}
  1500. proc texLogo {} {insertObject "\\TeX"}
  1501. proc latexLogo {} {insertObject "\\LaTeX"}
  1502. proc latex2eLogo {} {insertObject "\\LaTeXe"}
  1503. proc today {} {insertObject "\\today"}
  1504. proc dag {} {insertObject "\\dag"}
  1505. proc ddag {} {insertObject "\\ddag"}
  1506. proc sectionMark {} {insertObject "\\S"}
  1507. proc paragraphMark {} {insertObject "\\P"}
  1508. proc copyright {} {insertObject "\\copyright"}
  1509. proc pounds {} {insertObject "\\pounds"}
  1510. proc quotes {} {
  1511.     if {[wrapObject "`" "'•"]} then {
  1512.         message "text quoted"
  1513.     } else {
  1514.         message "enter text"
  1515.     }
  1516. }
  1517. proc dblQuotes {} {
  1518.     if {[wrapObject "``" "''•"]} then {
  1519.         message "text double quoted"
  1520.     } else {
  1521.         message "enter text"
  1522.     }
  1523. }
  1524. proc marginalNote {} {
  1525.     if {[wrapObject "\\marginpar{" "}•"]} then {
  1526.         message "marginal note set"
  1527.     } else {
  1528.         message "enter marginal note"
  1529.     }
  1530. }
  1531. proc footnote {} {
  1532.     if {[wrapObject "\\footnote{" "}•"]} then {
  1533.         message "footnote set"
  1534.     } else {
  1535.         message "enter footnote"
  1536.     }
  1537. }
  1538. proc label {} {
  1539.     if {[wrapObject "\\label{" "}•"]} then {
  1540.         message "label defined"
  1541.     } else {
  1542.         message "enter label"
  1543.     }
  1544. }
  1545. proc ref {} { 
  1546.     if {[wrapObject "\\ref{" "}•"]} then {
  1547.         message "cross-reference made"
  1548.     } else {
  1549.         message "enter cross-reference"
  1550.     }
  1551. }
  1552. proc pageref {} { 
  1553.     if {[wrapObject "\\pageref{" "}•"]} then {
  1554.         message "page reference made"
  1555.     } else {
  1556.         message "enter page reference"
  1557.     }
  1558. }
  1559. proc cite {} {
  1560.     if {[wrapObject "\\cite{" "}•"]} then {
  1561.         message "citation made"
  1562.     } else {
  1563.         message "enter citation"
  1564.     }
  1565. }
  1566. proc item {} {insertObject "\\item"}
  1567. proc bibitem {} {
  1568.     if {[wrapObject "\\bibitem{" "}•"]} then {
  1569.         message "bibitem set"
  1570.     } else {
  1571.         message "enter bibitem"
  1572.     }
  1573. }
  1574.  
  1575.  
  1576. #############################################################################
  1577. # Math Mode Macros
  1578. #
  1579. #############################################################################
  1580.  
  1581. #--------------------------------------------------------------------------
  1582. # Math Modes:
  1583. #--------------------------------------------------------------------------
  1584.  
  1585. proc texMath {} {
  1586.     if {[wrapObject "$" "$•"]} then {
  1587.         message "formula set"
  1588.     } else {
  1589.         message "enter formula"
  1590.     }
  1591. }
  1592. proc texDisplaymath {} {
  1593.     if {[wrapObject "$$" "$$•"]} then {
  1594.         message "displayed formula set"
  1595.     } else {
  1596.         message "enter displayed formula"
  1597.     }
  1598. }
  1599. proc latexMath {} {
  1600.     if {[wrapObject "\\( " " \\)•"]} then {
  1601.         message "formula set"
  1602.     } else {
  1603.         message "enter formula"
  1604.     }
  1605. }
  1606. proc latexDisplaymath {} {
  1607.     if {[wrapObject "\\\[ " " \\\]•"]} then {
  1608.         message "displayed formula set"
  1609.     } else {
  1610.         message "enter displayed formula"
  1611.     }
  1612. }
  1613.  
  1614. #--------------------------------------------------------------------------
  1615. # Math Style:
  1616. #--------------------------------------------------------------------------
  1617.  
  1618. proc mathit {} {
  1619.     if {[wrapObject "\\mathit{" "}•"]} then {
  1620.         message "selected text is math italic"
  1621.     } else {
  1622.         message "enter text to be math italic"
  1623.     }
  1624. }
  1625. proc mathrm {} {
  1626.     if {[wrapObject "\\mathrm{" "}•"]} then {
  1627.         message "selected text is math roman"
  1628.     } else {
  1629.         message "enter text to be math roman"
  1630.     }
  1631. }
  1632. proc mathbf {} {
  1633.     if {[wrapObject "\\mathbf{" "}•"]} then {
  1634.         message "selected text is math bold"
  1635.     } else {
  1636.         message "enter text to be math bold"
  1637.     }
  1638. }
  1639. proc mathsf {} {
  1640.     if {[wrapObject "\\mathsf{" "}•"]} then {
  1641.         message "selected text is math sans serif"
  1642.     } else {
  1643.         message "enter text to be math sans serif"
  1644.     }
  1645. }
  1646. proc mathtt {} {
  1647.     if {[wrapObject "\\mathtt{" "}•"]} then {
  1648.         message "selected text is math typewriter"
  1649.     } else {
  1650.         message "enter text to be math typewriter"
  1651.     }
  1652. }
  1653. proc mathcal {} {
  1654.     # Allow upper-case arguments only:
  1655.     if {[isSelection] && ![isUppercase]} then {
  1656.         alertnote "argument to \\mathcal must be uppercase"
  1657.         return
  1658.     }
  1659.     if {[wrapObject "\\mathcal{" "}•"]} then {
  1660.         message "selected text is calligraphic"
  1661.     } else {
  1662.         message "enter text to be calligraphic (UPPERCASE letters only)"
  1663.     }
  1664. }
  1665. proc displaystyle {} {
  1666.     if {[wrapObject "{\\displaystyle " "}•"]} then {
  1667.         message "displaystyle set"
  1668.     } else {
  1669.         message "enter displaystyle text"
  1670.     }
  1671. }
  1672. proc textstyle {} {
  1673.     if {[wrapObject "{\\textstyle " "}•"]} then {
  1674.         message "textstyle set"
  1675.     } else {
  1676.         message "enter textstyle text"
  1677.     }
  1678. }
  1679. proc scriptstyle {} {
  1680.     if {[wrapObject "{\\scriptstyle " "}•"]} then {
  1681.         message "scriptstyle set"
  1682.     } else {
  1683.         message "enter scriptstyle text"
  1684.     }
  1685. }
  1686. proc scriptscriptstyle {} {
  1687.     if {[wrapObject "{\\scriptscriptstyle " "}•"]} then {
  1688.         message "scriptscriptstyle set"
  1689.     } else {
  1690.         message "enter scriptscriptstyle text"
  1691.     }
  1692. }
  1693.  
  1694. #--------------------------------------------------------------------------
  1695. # Math Environments:
  1696. #--------------------------------------------------------------------------
  1697.  
  1698. proc math {} { doWrapEnvironment "math" }
  1699. proc displaymath {} { doWrapEnvironment "displaymath" }
  1700. proc equation {} {
  1701.     set envName "equation"
  1702.     set body "\t\\label{•}\r"
  1703.     if {[wrapEnvironment $envName "" $body]} then {
  1704.         set msgText "equation wrapped"
  1705.     } else {
  1706.         set msgText "enter equation"
  1707.     }
  1708.     nextTabStop
  1709.     message $msgText
  1710. }
  1711. proc myArray {} {
  1712.     global promptNoisily useStatusBar
  1713.     set envName "array"
  1714.     if {$promptNoisily && $useStatusBar} {beep}
  1715.     catch {sPrompt "$envName:  how many rows?" 3} numberRows
  1716.     if {$numberRows != "cancel"} then {
  1717.         if {$promptNoisily && $useStatusBar} {beep}
  1718.         catch {sPrompt "$envName:  how many columns?" 3} numberCols
  1719.         if {$numberCols != "cancel"} then {
  1720.             set arg "{"
  1721.             for {set j 1} {$j <= $numberCols} {incr j} {
  1722.                 append arg "c"
  1723.             }
  1724.             append arg "}"
  1725.             set row "\t[buildRow $numberCols]"
  1726.             for {set i 1} {$i < $numberRows} {incr i} {
  1727.                 append body $row
  1728.                 append body "  \\\\\r\t\r"
  1729.             }
  1730.             append body $row
  1731.             append body "\r"
  1732.             if {[insertEnvironment $envName $arg $body]} then {
  1733.                 nextTabStop
  1734.                 message "type first item"
  1735.             }
  1736.         }
  1737.     }
  1738. }
  1739. proc eqnarrayStar {} {
  1740.     global promptNoisily useStatusBar
  1741.     set envName "eqnarray*"
  1742.     if {$promptNoisily && $useStatusBar} {beep}
  1743.     catch {sPrompt "$envName:  how many rows?" 3} numberRows
  1744.     if {$numberRows != "cancel"} then {
  1745.         set row "\t[buildRow 3]"
  1746.         for {set i 1} {$i < $numberRows} {incr i} {
  1747.             append body $row
  1748.             append body "  \\\\\r"
  1749.         }
  1750.         append body $row
  1751.         append body "\r"
  1752.         if {[insertEnvironment $envName "" $body]} then {
  1753.             nextTabStop
  1754.             message "type first item"
  1755.         }
  1756.     }
  1757. }
  1758. proc eqnarray {} {
  1759.     global promptNoisily useStatusBar
  1760.     set envName "eqnarray"
  1761.     if {$promptNoisily && $useStatusBar} {beep}
  1762.     catch {sPrompt "$envName:  how many rows?" 3} numberRows
  1763.     if {$numberRows != "cancel"} then {
  1764.         set row "\t[buildRow 3]\r\t\\label{•}"
  1765.         for {set i 1} {$i < $numberRows} {incr i} {
  1766.             append body $row
  1767.             append body "  \\\\\r"
  1768.         }
  1769.         append body $row
  1770.         append body "\r"
  1771.         if {[insertEnvironment $envName "" $body]} then {
  1772.             nextTabStop
  1773.             message "type first item"
  1774.         }
  1775.     }
  1776. }
  1777.  
  1778. #--------------------------------------------------------------------------
  1779. # Formulas:
  1780. #--------------------------------------------------------------------------
  1781.  
  1782. proc subscript {} {
  1783.     if {[wrapObject "_{" "}•"]} then {
  1784.         message "subscript set"
  1785.     } else {
  1786.         message "enter subscript"
  1787.     }
  1788. }
  1789. proc superscript {} {
  1790.     if {[wrapObject "^{" "}•"]} then {
  1791.         message "superscript set"
  1792.     } else {
  1793.         message "enter superscript"
  1794.     }
  1795. }
  1796. proc fraction {} {
  1797.     set currentPos [getPos]
  1798.     if {[isSelection]} then {
  1799.         set selection [getSelect]
  1800.         set args [split $selection /]
  1801.         set len [llength $args]
  1802.         deleteText $currentPos [selEnd]
  1803.         if {$len == 1} then {
  1804.             insertText "\\frac{" $selection "}{•}•"
  1805.             goto $currentPos
  1806.             nextTabStop
  1807.             message "enter denominator"
  1808.         } else {
  1809.             set firstArg [lindex $args 0]
  1810.             set restArgs [lrange $args 1 [expr $len-1]]
  1811.             insertText "\\frac{" $firstArg "}{" [join $restArgs /] "}"
  1812.             if {$len > 2} {message "beware of multiple /"}
  1813.         }
  1814.     } else {
  1815.         insertText "\\frac{•}{•}•"
  1816.         goto $currentPos
  1817.         nextTabStop
  1818.         message "enter numerator"
  1819.     }
  1820. }
  1821. proc squareRoot {} {
  1822.     if {[wrapObject "\\sqrt{" "}•"]} then {
  1823.         message "square root set"
  1824.     } else {
  1825.         message "enter formula"
  1826.     }
  1827. }
  1828. proc nthRoot {} {
  1829.     if {[wrapObject "\\sqrt\[•\]{" "}•"]} then {
  1830.         message "enter root"
  1831.     } else {
  1832.         message "enter root, then formula"
  1833.     }
  1834. }
  1835. proc oneParameter {} {
  1836.     catch {prompt "Command name?" "sqrt"} commandName
  1837.     if {$commandName != "cancel"} {wrapObject "\\$commandName{" "}•"}
  1838. }
  1839. proc twoParameters {} {
  1840.     catch {prompt "Command name?" "frac"} commandName
  1841.     if {$commandName != "cancel"} then {
  1842.         set currentPos [getPos]
  1843.         if {[insertObject "\\$commandName{•}{•}•"]} then {
  1844.             goto $currentPos
  1845.             nextTabStop
  1846.         }
  1847.     }
  1848. }
  1849.  
  1850. #--------------------------------------------------------------------------
  1851. # Greek:
  1852. #--------------------------------------------------------------------------
  1853.  
  1854. proc alpha {} {insertObject "\\alpha"}
  1855. proc beta {} {insertObject "\\beta"}
  1856. proc gamma {} {insertObject "\\gamma"}
  1857. proc delta {} {insertObject "\\delta"}
  1858. proc epsilon {} {insertObject "\\epsilon"}
  1859. proc zeta {} {insertObject "\\zeta"}
  1860. proc eta {} {insertObject "\\eta"}
  1861. proc theta {} {insertObject "\\theta"}
  1862. proc iota {} {insertObject "\\iota"}
  1863. proc kappa {} {insertObject "\\kappa"}
  1864. proc lambda {} {insertObject "\\lambda"}
  1865. proc mu {} {insertObject "\\mu"}
  1866. proc nu {} {insertObject "\\nu"}
  1867. proc xi {} {insertObject "\\xi"}
  1868. proc omicron {} {insertObject "o"}
  1869. proc pi {} {insertObject "\\pi"}
  1870. proc rho {} {insertObject "\\rho"}
  1871. proc sigma {} {insertObject "\\sigma"}
  1872. proc tau {} {insertObject "\\tau"}
  1873. proc upsilon {} {insertObject "\\upsilon"}
  1874. proc phi {} {insertObject "\\phi"}
  1875. proc chi {} {insertObject "\\chi"}
  1876. proc psi {} {insertObject "\\psi"}
  1877. proc omega {} {insertObject "\\omega"}
  1878.  
  1879. proc Gamma {} {insertObject "\\Gamma"}
  1880. proc Delta {} {insertObject "\\Delta"}
  1881. proc Theta {} {insertObject "\\Theta"}
  1882. proc Lambda {} {insertObject "\\Lambda"}
  1883. proc Xi {} {insertObject "\\Xi"}
  1884. proc Pi {} {insertObject "\\Pi"}
  1885. proc Sigma {} {insertObject "\\Sigma"}
  1886. proc Upsilon {} {insertObject "\\Upsilon"}
  1887. proc Phi {} {insertObject "\\Phi"}
  1888. proc Psi {} {insertObject "\\Psi"}
  1889. proc Omega {} {insertObject "\\Omega"}
  1890.  
  1891. proc varepsilon {} {insertObject "\\varepsilon"}
  1892. proc vartheta {} {insertObject "\\vartheta"}
  1893. proc varpi {} {insertObject "\\varpi"}
  1894. proc varrho {} {insertObject "\\varrho"}
  1895. proc varsigma {} {insertObject "\\varsigma"}
  1896. proc varphi {} {insertObject "\\varphi"}
  1897.  
  1898. #--------------------------------------------------------------------------
  1899. # Binary Ops:
  1900. #--------------------------------------------------------------------------
  1901.  
  1902. proc pm {} {insertObject "\\pm"}
  1903. proc mp {} {insertObject "\\mp"}
  1904. proc times {} {insertObject "\\times"}
  1905. proc div {} {insertObject "\\div"}
  1906. proc ast {} {insertObject "\\ast"}
  1907. proc star {} {insertObject "\\star"}
  1908. proc circ {} {insertObject "\\circ"}
  1909. proc bullet {} {insertObject "\\bullet"}
  1910. proc cdot {} {insertObject "\\cdot"}
  1911. proc cap {} {insertObject "\\cap"}
  1912. proc cup {} {insertObject "\\cup"}
  1913. proc uplus {} {insertObject "\\uplus"}
  1914. proc sqcap {} {insertObject "\\sqcap"}
  1915. proc sqcup {} {insertObject "\\sqcup"}
  1916. proc vee {} {insertObject "\\vee"}
  1917. proc wedge {} {insertObject "\\wedge"}
  1918. proc setminus {} {insertObject "\\setminus"}
  1919. proc wr {} {insertObject "\\wr"}
  1920. proc diamond {} {insertObject "\\diamond"}
  1921. proc bigtriangleup {} {insertObject "\\bigtriangleup"}
  1922. proc bigtriangledown {} {insertObject "\\bigtriangledown"}
  1923. proc triangleleft {} {insertObject "\\triangleleft"}
  1924. proc triangleright {} {insertObject "\\triangleright"}
  1925. proc lhd {} { if {[isSymbolPackageLoaded]} then {insertObject "\\lhd"} }
  1926. proc rhd {} { if {[isSymbolPackageLoaded]} then {insertObject "\\rhd"} }
  1927. proc unlhd {} { if {[isSymbolPackageLoaded]} then {insertObject "\\unlhd"} }
  1928. proc unrhd {} { if {[isSymbolPackageLoaded]} then {insertObject "\\unrhd"} }
  1929. proc oplus {} {insertObject "\\oplus"}
  1930. proc ominus {} {insertObject "\\ominus"}
  1931. proc otimes {} {insertObject "\\otimes"}
  1932. proc oslash {} {insertObject "\\oslash"}
  1933. proc odot {} {insertObject "\\odot"}
  1934. proc bigcirc {} {insertObject "\\bigcirc"}
  1935. proc dagger {} {insertObject "\\dagger"}
  1936. proc ddagger {} {insertObject "\\ddagger"}
  1937. proc amalg {} {insertObject "\\amalg"}
  1938.  
  1939. #--------------------------------------------------------------------------
  1940. # Relations:
  1941. #--------------------------------------------------------------------------
  1942.  
  1943. proc leq {} {insertObject "\\leq"}
  1944. proc prec {} {insertObject "\\prec"}
  1945. proc preceq {} {insertObject "\\preceq"}
  1946. proc myLl {} {insertObject "\\ll"}
  1947. proc subset {} {insertObject "\\subset"}
  1948. proc subseteq {} {insertObject "\\subseteq"}
  1949. proc sqsubset {} {
  1950.     if {[isSymbolPackageLoaded]} then {insertObject "\\sqsubset"}
  1951. }
  1952. proc sqsubseteq {} {insertObject "\\sqsubseteq"}
  1953. proc in {} {insertObject "\\in"}
  1954. proc vdash {} {insertObject "\\vdash"}
  1955.  
  1956. proc geq {} {insertObject "\\geq"}
  1957. proc succ {} {insertObject "\\succ"}
  1958. proc succeq {} {insertObject "\\succeq"}
  1959. proc gg {} {insertObject "\\gg"}
  1960. proc supset {} {insertObject "\\supset"}
  1961. proc supseteq {} {insertObject "\\supseteq"}
  1962. proc sqsupset {} {
  1963.     if {[isSymbolPackageLoaded]} then {insertObject "\\sqsupset"}
  1964. }
  1965. proc sqsupseteq {} {insertObject "\\sqsupseteq"}
  1966. proc ni {} {insertObject "\\ni"}
  1967. proc dashv {} {insertObject "\\dashv"}
  1968.  
  1969. proc equiv {} {insertObject "\\equiv"}
  1970. proc sim {} {insertObject "\\sim"}
  1971. proc simeq {} {insertObject "\\simeq"}
  1972. proc asymp {} {insertObject "\\asymp"}
  1973. proc approx {} {insertObject "\\approx"}
  1974. proc cong {} {insertObject "\\cong"}
  1975. proc neq {} {insertObject "\\neq"}
  1976. proc doteq {} {insertObject "\\doteq"}
  1977. proc propto {} {insertObject "\\propto"}
  1978.  
  1979. proc models {} {insertObject "\\models"}
  1980. proc perp {} {insertObject "\\perp"}
  1981. proc mid {} {insertObject "\\mid"}
  1982. proc parallel {} {insertObject "\\parallel"}
  1983. proc bowtie {} {insertObject "\\bowtie"}
  1984. proc myJoin {} { if {[isSymbolPackageLoaded]} then {insertObject "\\join"} }
  1985. proc smile {} {insertObject "\\smile"}
  1986. proc frown {} {insertObject "\\frown"}
  1987.  
  1988. #--------------------------------------------------------------------------
  1989. # Arrows:
  1990. #--------------------------------------------------------------------------
  1991.  
  1992. proc leftarrow {} {insertObject "\\leftarrow"}
  1993. proc Leftarrow {} {insertObject "\\Leftarrow"}
  1994. proc rightarrow {} {insertObject "\\rightarrow"}
  1995. proc Rightarrow {} {insertObject "\\Rightarrow"}
  1996. proc leftrightarrow {} {insertObject "\\leftrightarrow"}
  1997. proc Leftrightarrow {} {insertObject "\\Leftrightarrow"}
  1998. proc mapsto {} {insertObject "\\mapsto"}
  1999. proc hookleftarrow {} {insertObject "\\hookleftarrow"}
  2000. proc leftharpoonup {} {insertObject "\\leftharpoonup"}
  2001. proc leftharpoondown {} {insertObject "\\leftharpoondown"}
  2002. proc rightleftharpoons {} {insertObject "\\rightleftharpoons"}
  2003.  
  2004. proc longleftarrow {} {insertObject "\\longleftarrow"}
  2005. proc Longleftarrow {} {insertObject "\\Longleftarrow"}
  2006. proc longrightarrow {} {insertObject "\\longrightarrow"}
  2007. proc Longrightarrow {} {insertObject "\\Longrightarrow"}
  2008. proc longleftrightarrow {} {insertObject "\\longleftrightarrow"}
  2009. proc Longleftrightarrow {} {insertObject "\\Longleftrightarrow"}
  2010. proc longmapsto {} {insertObject "\\longmapsto"}
  2011. proc hookrightarrow {} {insertObject "\\hookrightarrow"}
  2012. proc rightharpoonup {} {insertObject "\\rightharpoonup"}
  2013. proc rightharpoondown {} {insertObject "\\rightharpoondown"}
  2014. proc leadsto {} {
  2015.     if {[isSymbolPackageLoaded]} then {insertObject "\\leadsto"}
  2016. }
  2017. proc uparrow {} {insertObject "\\uparrow"}
  2018. proc Uparrow {} {insertObject "\\Uparrow"}
  2019. proc downarrow {} {insertObject "\\downarrow"}
  2020. proc Downarrow {} {insertObject "\\Downarrow"}
  2021. proc updownarrow {} {insertObject "\\updownarrow"}
  2022. proc Updownarrow {} {insertObject "\\Updownarrow"}
  2023. proc nearrow {} {insertObject "\\nearrow"}
  2024. proc searrow {} {insertObject "\\searrow"}
  2025. proc swarrow {} {insertObject "\\swarrow"}
  2026. proc nwarrow {} {insertObject "\\nwarrow"}
  2027.  
  2028. #--------------------------------------------------------------------------
  2029. # Dots:
  2030. #--------------------------------------------------------------------------
  2031.  
  2032. proc cdots {} {insertObject "\\cdots"}
  2033. proc vdots {} {insertObject "\\vdots"}
  2034. proc ddots {} {insertObject "\\ddots"}
  2035.  
  2036. #--------------------------------------------------------------------------
  2037. # Symbols:
  2038. #--------------------------------------------------------------------------
  2039.  
  2040. proc aleph {} {insertObject "\\aleph"}
  2041. proc hbar {} {insertObject "\\hbar"}
  2042. proc imath {} {insertObject "\\imath"}
  2043. proc jmath {} {insertObject "\\jmath"}
  2044. proc ell {} {insertObject "\\ell"}
  2045. proc wp {} {insertObject "\\wp"}
  2046. proc Re {} {insertObject "\\Re"}
  2047. proc Im {} {insertObject "\\Im"}
  2048. proc mho {} { if {[isSymbolPackageLoaded]} then {insertObject "\\mho"} }
  2049. proc prime {} {insertObject "\\prime"}
  2050. proc emptyset {} {insertObject "\\emptyset"}
  2051. proc nabla {} {insertObject "\\nabla"}
  2052. proc surd {} {insertObject "\\surd"}
  2053. proc top {} {insertObject "\\top"}
  2054. proc bot {} {insertObject "\\bot"}
  2055. # proc | {} {insertObject "\\|"}
  2056. proc angle {} {insertObject "\\angle"}
  2057. proc forall {} {insertObject "\\forall"}
  2058. proc exists {} {insertObject "\\exists"}
  2059. proc neg {} {insertObject "\\neg"}
  2060. proc flat {} {insertObject "\\flat"}
  2061. proc natural {} {insertObject "\\natural"}
  2062. proc sharp {} {insertObject "\\sharp"}
  2063. proc backslash {} {insertObject "\\backslash"}
  2064. proc partial {} {insertObject "\\partial"}
  2065. proc infty {} {insertObject "\\infty"}
  2066. proc Box {} { if {[isSymbolPackageLoaded]} then {insertObject "\\Box"} }
  2067. proc Diamond {} {
  2068.     if {[isSymbolPackageLoaded]} then {insertObject "\\Diamond"}
  2069. }
  2070. proc triangle {} {insertObject "\\triangle"}
  2071. proc clubsuit {} {insertObject "\\clubsuit"}
  2072. proc diamondsuit {} {insertObject "\\diamondsuit"}
  2073. proc heartsuit {} {insertObject "\\heartsuit"}
  2074. proc spadesuit {} {insertObject "\\spadesuit"}
  2075.  
  2076. #--------------------------------------------------------------------------
  2077. # Functions:
  2078. #--------------------------------------------------------------------------
  2079.  
  2080. proc arccos {} {insertObject "\\arccos"}
  2081. proc arcsin {} {insertObject "\\arcsin"}
  2082. proc arctan {} {insertObject "\\arctan"}
  2083. proc arg {} {insertObject "\\arg"}
  2084. proc cos {} {insertObject "\\cos"}
  2085. proc cosh {} {insertObject "\\cosh"}
  2086. proc cot {} {insertObject "\\cot"}
  2087. proc coth {} {insertObject "\\coth"}
  2088. proc csc {} {insertObject "\\csc"}
  2089. proc deg {} {insertObject "\\deg"}
  2090. proc det {} {insertObject "\\det"}
  2091. proc dim {} {insertObject "\\dim"}
  2092. proc exp {} {insertObject "\\exp"}
  2093. proc gcd {} {insertObject "\\gcd"}
  2094. proc hom {} {insertObject "\\hom"}
  2095. proc inf {} {insertObject "\\inf"}
  2096. proc ker {} {insertObject "\\ker"}
  2097. proc lg {} {insertObject "\\lg"}
  2098. proc lim {} {insertObject "\\lim"}
  2099. proc liminf {} {insertObject "\\liminf"}
  2100. proc limsup {} {insertObject "\\limsup"}
  2101. proc ln {} {insertObject "\\ln"}
  2102. proc log {} {insertObject "\\log"}
  2103. proc max {} {insertObject "\\max"}
  2104. proc min {} {insertObject "\\min"}
  2105. proc Pr {} {insertObject "\\Pr"}
  2106. proc sec {} {insertObject "\\sec"}
  2107. proc sin {} {insertObject "\\sin"}
  2108. proc sinh {} {insertObject "\\sinh"}
  2109. proc sup {} {insertObject "\\sup"}
  2110. proc tan {} {insertObject "\\tan"}
  2111. proc tanh {} {insertObject "\\tanh"}
  2112.  
  2113. proc bmod {} {insertObject "\\bmod"}
  2114. proc pmod {} {
  2115.     if {[wrapObject "\\pmod{" "}•"]} then {
  2116.         message "parenthesized mod set"
  2117.     } else {
  2118.         message "enter formula"
  2119.     }
  2120. }
  2121.  
  2122. #--------------------------------------------------------------------------
  2123. # Large Ops:
  2124. #--------------------------------------------------------------------------
  2125.  
  2126. proc insertLargeOp {commandName} {
  2127.     set currentPos [getPos]
  2128.     insertText "\\$commandName"
  2129.     insertText "_{•}^{•}•"
  2130.     goto $currentPos
  2131.     nextTabStop
  2132. }
  2133. proc sum {} {insertLargeOp "sum"}
  2134. proc prod {} {insertLargeOp "prod"}
  2135. proc coprod {} {insertLargeOp "coprod"}
  2136. proc int {} {insertLargeOp "int"}
  2137. proc oint {} {insertLargeOp "oint"}
  2138. proc bigcap {} {insertLargeOp "bigcap"}
  2139. proc bigcup {} {insertLargeOp "bigcup"}
  2140. proc bigsqcap {} {insertLargeOp "bigsqcap"}
  2141. proc bigsqcup {} {insertLargeOp "bigsqcup"}
  2142. proc bigvee {} {insertLargeOp "bigvee"}
  2143. proc bigwedge {} {insertLargeOp "bigwedge"}
  2144. proc bigodot {} {insertLargeOp "bigodot"}
  2145. proc bigotimes {} {insertLargeOp "bigotimes"}
  2146. proc bigoplus {} {insertLargeOp "bigoplus"}
  2147. proc biguplus {} {insertLargeOp "biguplus"}
  2148.  
  2149. #--------------------------------------------------------------------------
  2150. # Delimiters:
  2151. #--------------------------------------------------------------------------
  2152.  
  2153. proc delimitObject {leftDelim rightDelim} {
  2154.     if {[wrapObject $leftDelim $rightDelim]} then {
  2155.         message "formula delimited"
  2156.     } else {
  2157.         message "enter formula"
  2158.     }
  2159. }
  2160. proc parentheses {} { delimitObject "(" ")•" }
  2161. proc brackets {} { delimitObject "\[" "\]•" }
  2162. proc braces {} { delimitObject "\\\{" "\\\}•" }
  2163. proc absoluteValue {} { delimitObject "|" "|•" }
  2164. proc getDelims {} {
  2165.     catch {prompt "Choose delimiters:" "parentheses" "" "parentheses" \
  2166.                   "brackets" "braces" "angle brackets" "vertical bars" \
  2167.                   "double bars" "ceiling" "floor"} delimType
  2168.     if {$delimType != "cancel"} then {
  2169.         case $delimType in {
  2170.             "parentheses" {
  2171.                 set leftDelim "("
  2172.                 set rightDelim ")"
  2173.             }
  2174.             "brackets" {
  2175.                 set leftDelim "\["
  2176.                 set rightDelim "\]"
  2177.             }
  2178.             "braces" {
  2179.                 set leftDelim "\\\{"
  2180.                 set rightDelim "\\\}"
  2181.             }
  2182.             "{vertical bars}" {
  2183.                 set leftDelim "|"
  2184.                 set rightDelim "|"
  2185.             }
  2186.             "{double bars}" {
  2187.                 set leftDelim "\\|"
  2188.                 set rightDelim "\\|"
  2189.             }
  2190.             "{angle brackets}" {
  2191.                 set leftDelim "\\langle"
  2192.                 set rightDelim "\\rangle"
  2193.             }
  2194.             "ceiling" {
  2195.                 set leftDelim "\\lceil"
  2196.                 set rightDelim "\\rceil"
  2197.             }
  2198.             "floor" {
  2199.                 set leftDelim "\\lfloor"
  2200.                 set rightDelim "\\rfloor"
  2201.             }
  2202.             default {
  2203.                 alertnote "\"$delimType\" not recognized"
  2204.                 return ""
  2205.             }
  2206.         }
  2207.         return [list $leftDelim $rightDelim]
  2208.     } else {return ""}
  2209. }
  2210. proc otherDelims {} {
  2211.     set delims [getDelims]
  2212.     if {$delims != ""} then {
  2213.         set leftDelim [lindex $delims 0]
  2214.         set rightDelim [lindex $delims 1]
  2215.         delimitObject "$leftDelim" "$rightDelim•"
  2216.     }
  2217. }
  2218. proc {half-openInterval} {} { delimitObject "(" "\]•" }
  2219. proc {half-closedInterval} {} { delimitObject "\[" ")•" }
  2220. proc bigParentheses {} { delimitObject "\\left(" "\\right)•" }
  2221. proc bigBrackets {} { delimitObject "\\left\[" "\\right\]•" }
  2222. proc bigBraces {} { delimitObject "\\left\\\{" "\\right\\\}•" }
  2223. proc bigAbsoluteValue {} { delimitObject "\\left|" "\\right|•" }
  2224. proc otherBigDelims {} {
  2225.     set delims [getDelims]
  2226.     if {$delims != ""} then {
  2227.         append leftDelim "\\left" [lindex $delims 0]
  2228.         append rightDelim "\\right" [lindex $delims 1]
  2229.         delimitObject "$leftDelim" "$rightDelim•"
  2230.     }
  2231. }
  2232. proc bigLeftBrace {} { delimitObject "\\left\\\{" "\\right.•" }
  2233. proc otherMixedBigDelims {} {
  2234.     catch {prompt "Choose LEFT delimiter:" "parenthesis" "" "parenthesis" \
  2235.                   "bracket" "brace" "vertical bar" "double bar" \
  2236.                   "angle bracket" "ceiling" "floor" "slash" "backslash" \
  2237.                   "none"} delimType
  2238.     if {$delimType != "cancel"} then {
  2239.         case $delimType in {
  2240.             "parenthesis" {set leftDelim "("}
  2241.             "bracket" {set leftDelim "\["}
  2242.             "brace" {set leftDelim "\\\{"}
  2243.             "{vertical bar}" {set leftDelim "|"}
  2244.             "{double bar}" {set leftDelim "\\|"}
  2245.             "{angle bracket}" {set leftDelim "\\langle"}
  2246.             "ceiling" {set leftDelim "\\lceil"}
  2247.             "floor" {set leftDelim "\\lfloor"}
  2248.             "slash" {set leftDelim "/"}
  2249.             "backslash" {set leftDelim "\\backslash"}
  2250.             "none" {set leftDelim "."}
  2251.             default {
  2252.                 alertnote "\"$delimType\" not recognized"
  2253.                 return
  2254.             }
  2255.         }
  2256.         catch {prompt "Choose RIGHT delimiter:" "parenthesis" "" "parenthesis" \
  2257.                       "bracket" "brace" "vertical bar" "double bar" \
  2258.                       "angle bracket" "ceiling" "floor" "slash" "backslash" \
  2259.                       "none"} delimType
  2260.         if {$delimType != "cancel"} then {
  2261.             case $delimType in {
  2262.                 "parenthesis" {set rightDelim ")"}
  2263.                 "bracket" {set rightDelim "\]"}
  2264.                 "brace" {set rightDelim "\\\}"}
  2265.                 "{vertical bar}" {set rightDelim "|"}
  2266.                 "{double bar}" {set rightDelim "\\|"}
  2267.                 "{angle bracket}" {set rightDelim "\\rangle"}
  2268.                 "ceiling" {set rightDelim "\\rceil"}
  2269.                 "floor" {set rightDelim "\\rfloor"}
  2270.                 "slash" {set rightDelim "/"}
  2271.                 "backslash" {set rightDelim "\\backslash"}
  2272.                 "none" {set rightDelim "."}
  2273.                 default {
  2274.                     alertnote "\"$delimType\" not recognized"
  2275.                     return
  2276.                 }
  2277.             }
  2278.             delimitObject "\\left$leftDelim" "\\right$rightDelim•"
  2279.         }
  2280.     }
  2281. }
  2282.  
  2283. #--------------------------------------------------------------------------
  2284. # Accents:
  2285. #--------------------------------------------------------------------------
  2286.  
  2287. proc acute {} {
  2288.     if {[isSelection] > 1} then {
  2289.         alertnote "Warning: only a single character may be accented!"
  2290.     }
  2291.     if {[wrapObject "\\acute{" "}•"]} then {
  2292.         message "accent set"
  2293.     } else {
  2294.         message "enter one character"
  2295.     }
  2296. }
  2297. proc bar {} {
  2298.     if {[isSelection] > 1} then {
  2299.         alertnote "Warning: only a single character may be accented!"
  2300.     }
  2301.     if {[wrapObject "\\bar{" "}•"]} then {
  2302.         message "accent set"
  2303.     } else {
  2304.         message "enter one character"
  2305.     }
  2306. }
  2307. proc breve {} {
  2308.     if {[isSelection] > 1} then {
  2309.         alertnote "Warning: only a single character may be accented!"
  2310.     }
  2311.     if {[wrapObject "\\breve{" "}•"]} then {
  2312.         message "accent set"
  2313.     } else {
  2314.         message "enter one character"
  2315.     }
  2316. }
  2317. proc check {} {
  2318.     if {[isSelection] > 1} then {
  2319.         alertnote "Warning: only a single character may be accented!"
  2320.     }
  2321.     if {[wrapObject "\\check{" "}•"]} then {
  2322.         message "accent set"
  2323.     } else {
  2324.         message "enter one character"
  2325.     }
  2326. }
  2327. proc dot {} {
  2328.     if {[isSelection] > 1} then {
  2329.         alertnote "Warning: only a single character may be accented!"
  2330.     }
  2331.     if {[wrapObject "\\dot{" "}•"]} then {
  2332.         message "accent set"
  2333.     } else {
  2334.         message "enter one character"
  2335.     }
  2336. }
  2337. proc ddot {} {
  2338.     if {[isSelection] > 1} then {
  2339.         alertnote "Warning: only a single character may be accented!"
  2340.     }
  2341.     if {[wrapObject "\\ddot{" "}•"]} then {
  2342.         message "accent set"
  2343.     } else {
  2344.         message "enter one character"
  2345.     }
  2346. }
  2347. proc grave {} {
  2348.     if {[isSelection] > 1} then {
  2349.         alertnote "Warning: only a single character may be accented!"
  2350.     }
  2351.     if {[wrapObject "\\grave{" "}•"]} then {
  2352.         message "accent set"
  2353.     } else {
  2354.         message "enter one character"
  2355.     }
  2356. }
  2357. proc hat {} {
  2358.     if {[isSelection] > 1} then {
  2359.         alertnote "Warning: only a single character may be accented!"
  2360.     }
  2361.     if {[wrapObject "\\hat{" "}•"]} then {
  2362.         message "accent set"
  2363.     } else {
  2364.         message "enter one character"
  2365.     }
  2366. }
  2367. proc tilde {} {
  2368.     if {[isSelection] > 1} then {
  2369.         alertnote "Warning: only a single character may be accented!"
  2370.     }
  2371.     if {[wrapObject "\\tilde{" "}•"]} then {
  2372.         message "accent set"
  2373.     } else {
  2374.         message "enter one character"
  2375.     }
  2376. }
  2377. proc vec {} {
  2378.     if {[isSelection] > 1} then {
  2379.         alertnote "Warning: only a single character may be accented!"
  2380.     }
  2381.     if {[wrapObject "\\vec{" "}•"]} then {
  2382.         message "accent set"
  2383.     } else {
  2384.         message "enter one character"
  2385.     }
  2386. }
  2387.  
  2388. proc widehat {} {
  2389.     if {[isSelection] > 3} then {
  2390.         alertnote "Warning: only a few characters may be accented!"
  2391.     }
  2392.     if {[wrapObject "\\widehat{" "}•"]} then {
  2393.         message "accent set"
  2394.     } else {
  2395.         message "enter a few characters"
  2396.     }
  2397. }
  2398. proc widetilde {} {
  2399.     if {[isSelection] > 3} then {
  2400.         alertnote "Warning: only a few characters may be accented!"
  2401.     }
  2402.     if {[wrapObject "\\widetilde{" "}•"]} then {
  2403.         message "accent set"
  2404.     } else {
  2405.         message "enter a few characters"
  2406.     }
  2407. }
  2408.  
  2409. proc imath {} {insertObject "\\imath"}
  2410. proc jmath {} {insertObject "\\jmath"}
  2411.  
  2412. #--------------------------------------------------------------------------
  2413. # Grouping:
  2414. #--------------------------------------------------------------------------
  2415.  
  2416. proc underline {} {
  2417.     if {[wrapObject "\\underline{" "}•"]} then {
  2418.         message "selection underlined"
  2419.     } else {
  2420.         message "enter text"
  2421.     }
  2422. }
  2423. proc overline {} {
  2424.     if {[wrapObject "\\overline{" "}•"]} then {
  2425.         message "selection overlined"
  2426.     } else {
  2427.         message "enter text"
  2428.     }
  2429. }
  2430. proc underbrace {} {
  2431.     if {[wrapObject "\\underbrace{" "}•"]} then {
  2432.         message "selection underbraced"
  2433.     } else {
  2434.         message "enter text"
  2435.     }
  2436. }
  2437. proc overbrace {} {
  2438.     if {[wrapObject "\\overbrace{" "}•"]} then {
  2439.         message "selection overbraced"
  2440.     } else {
  2441.         message "enter text"
  2442.     }
  2443. }
  2444. proc stackrel {} {
  2445.     set currentPos [getPos]
  2446.     if {[insertObject "\\stackrel{•}{•}•"]} then {
  2447.         goto $currentPos
  2448.         nextTabStop
  2449.         message "1st arg scriptstyle"
  2450.     }
  2451. }
  2452.  
  2453. #--------------------------------------------------------------------------
  2454. # Spacing:
  2455. #--------------------------------------------------------------------------
  2456.  
  2457. proc negThin {} {insertObject "\\!"}
  2458. proc thin {} {insertObject "\\,"}
  2459. proc medium {} {insertObject "\\:"}
  2460. proc thick {} {insertObject "\\;"}
  2461. proc quad {} {insertObject "\\quad"}
  2462. proc qquad {} {insertObject "\\qquad"}
  2463. proc hspace {} {
  2464.     if {[wrapObject "\\hspace{" "}•"]} then {
  2465.         message "spacing set"
  2466.     } else {
  2467.         message "enter the desired horizontal spacing"
  2468.     }
  2469. }
  2470. proc vspace {} {
  2471.     if {[wrapObject "\\vspace{" "}•"]} then {
  2472.         message "spacing set"
  2473.     } else {
  2474.         message "enter the desired horizontal spacing"
  2475.     }
  2476. }
  2477. proc hfill {} {insertObject "\\hfill"}
  2478. proc vfill {} {insertObject "\\vfill"}
  2479. proc smallskip {} {insertObject "\\smallskip"}
  2480. proc medskip {} {insertObject "\\medskip"}
  2481. proc bigskip {} {insertObject "\\bigskip"}
  2482.  
  2483.  
  2484. #############################################################################
  2485. #
  2486. # LaTeX Menu Definition
  2487. #
  2488. # (see file "latexMenu.tcl")
  2489. #
  2490. #############################################################################
  2491.  
  2492. source "$HOME:Tcl:SystemCode:latexMenu.tcl"
  2493. buildLaTeXMenu
  2494.  
  2495.  
  2496. #############################################################################
  2497. #
  2498. # Special LaTeX Key Bindings
  2499. #
  2500. # (see file "latexKeys.tcl")
  2501. #
  2502. #############################################################################
  2503.  
  2504. source "$HOME:Tcl:SystemCode:latexKeys.tcl"
  2505. bindLaTeXKeys
  2506.  
  2507.